package com.warehouse_management.market.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.warehouse_management.config.PageModel;
import com.warehouse_management.market.dao.IMarketDao;
import com.warehouse_management.market.model.Custom;
import com.warehouse_management.market.model.Orde;
import com.warehouse_management.market.model.OrdeCondition;
import com.warehouse_management.market.model.Orderdetails;
import com.warehouse_management.market.service.IMarketOrdeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ImplMarketOrde implements IMarketOrdeService {

    @Autowired
    private IMarketDao marketDao;

    public IMarketDao getMarketDao() {
        return marketDao;
    }

    public void setMarketDao(IMarketDao marketDao) {
        this.marketDao = marketDao;
    }

    @Override
    public List<Orde> queryAllOrde() {
        return marketDao.queryAllOrde();
    }

    /*
     *
     * @PACKAGE_NAME: com.warehouse_management.system.controller
     * @NAME: toPositionList
     * @USER: WanWenCheng
     * @DATE: 2022/10/2
     * @TIME: 20：56
     * @Description: 订单分页
     * */
    @Override
    public PageModel<Orde> PageOrde(Orde orde, PageModel<Orde> pageModel) {
        pageModel.setPageNum(pageModel.getPageNum()<=0?1:pageModel.getPageNum());
        pageModel.setPageSize(pageModel.getPageSize()<=0?3:pageModel.getPageSize());

        PageHelper.startPage(pageModel.getPageNum(),pageModel.getPageSize());
        List<Orde> customList = marketDao.queryAllOrde();

        PageInfo<Orde> pageInfo = new PageInfo<>(customList);

        pageModel.setTotalPage(pageInfo.getPages());
        pageModel.setTotalRows(pageInfo.getTotal());
        pageModel.setData(customList);
        return pageModel;
    }

    @Override
    public Orde queryOneOrde(Orde orde) {
        return marketDao.queryOneOrde(orde);
    }

    @Override
    public List<Orderdetails> queryOneOrderDetails(Orderdetails orderdetails) {
        return marketDao.queryOneOrderDetails(orderdetails);
    }

    @Override
    public List<Orde> queryOrdeByCondition(OrdeCondition condition) {
        return marketDao.queryOrdeByCondition(condition);
    }

    @Override
    public int updateSuggest(Orde orde) {
        return marketDao.updateSuggest(orde);
    }


}
